<style>
#load{
    width:100%;
    height:100%;
    position:fixed;
    z-index:9999;
    background:url("images/loading_bar.gif") no-repeat center center #fff;
}
</style>
<style>
#message {
    -moz-appearance: textfield-multiline;
    -webkit-appearance: textarea;
    border:1px solid rgb(204, 204, 204);
    font: medium -moz-fixed;
    font: -webkit-small-control;
    height: 179px;
    overflow: auto;
    padding: 2px;
    resize: both;
    width: 494px;
}
.list_item{
 margin-left: -33px;
 padding:5px;
  font: medium -moz-fixed;
  font: -webkit-small-control;
}
.list_itemP{
border-bottom: 2px solid #DDDDDD;
color: #025900;
display: block;
margin: -10px;
padding: 5px;
text-align: center;
}
.list_itemDiv{
	border: 1px solid #DDDDDD;
    float: right;
    margin-left: 100px;
    margin-top: -397px;
    padding: 10px;
    width: 150px;
}
</style>
<script>
document.onreadystatechange = function () {
	var path = window.location.href;
    path = path.replace(/\/$/, "");
    path = decodeURIComponent(path);
	var pageUrl		=	path;
	sessionStorage.setItem( 'pageUrl', JSON.stringify(pageUrl) );
	
	
  var state = document.readyState
  if (state == 'interactive') {
       document.getElementById('contents').style.visibility="hidden";
  } else if (state == 'complete') {
      setTimeout(function(){
	   if(typeof sessionStorage["admin_user_id"]!='undefined'){
			document.getElementById('interactive');
			document.getElementById('load').style.visibility="hidden";
			document.getElementById('contents').style.visibility="visible";
		 }else{
			window.location="index.html";
		 }
      },400);
  }
}
</script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script src="js/webserviceurl.js"></script>
<script src="js/validations.js"></script>
<script src="js/commonfunctions.js"></script>
<script src="js/text.js"></script>
<link href="css/style.css" rel="stylesheet">
<link href="css/default.css" rel="stylesheet">
<link href="css/responsive.css" rel="stylesheet">
<script>
$(function() {
$('#sidemenu').load('side-menu.html');
$('#header').load('header.html');
$('#footer').load('footer.html');
});
</script>
<div id="load"></div>
<div id="contents">
  <div id="header"></div>
    <div class="container-fluid">
      <div class="row-fluid container_bg">
        <div id="sidemenu"></div>
        <div class="span9 pos_r">
			<div class="container_title">
				<div class=""><h1>News Letter</h1></div>
				
<div style="width:800px;">
<div class="boxMiddle" id="listContent">
<span id="successmsg" style="color:red" class="adminNewsLetter"></span>
		 <div class="tab-content">
			 <div id="inline1" class="tab-pane active" style="width:600px; min-height:100px; padding:10px 10px;">
			<div class="PopUp">
			<form enctype="multipart/form-data" id="messageform" name="messageform" method="POST">
			<span id="msg_nr">
			<div class="pad_t8">
			<label>Subject&nbsp;&nbsp;&nbsp;</label><input type="text" id="subject" style="border:1px solid #ccc;height:25px;width:480px" name="subject" value="" /><span id="errorSubject" name="errorSubject" style="color:red"></span>
			<div class="clear hig20"></div>
			</div>
			</span>
			</br/>
		<table border="0" cellpadding="0" cellspacing="0" style="margin-right:50px;">
			<tr>			
				<td valign="top"><label>Message&nbsp;&nbsp;&nbsp;</label></td>
				<td> 
					<textarea  id="message" name="message" contenteditable="true" class="editablecontent"></textarea><span id="errorMessage" name="errorMessage" style="color:red"></span>
				</td>			
			</tr>
		</table>
		
		<div class="pad_t8 pad_1108"><div>&nbsp;</div>
		<a href="javascript:void(0);" class="btn btn-success myBtnStyle1" onclick="valid_messageform2();">Send Email</a>
		<div class="clearBoth"></div>
		</div>
		</form>
		</div>
		</div>
		</div>
		 <div style="clear:both"></div>
		<!--<div class="list_itemDiv">
			<p class="list_itemP">Please use below activity</p>
			<ul style="list-style:none;text-align:left;">
				<li class="list_item">
					{FIRSTNAME}
				</li>
				<li class="list_item">
					{LONGDATE}
				</li>
				<li class="list_item">
					{ABRIVATED}
				</li>
				<li class="list_item">
					{SHORTDATE}
				</li>
				<li class="list_item">
					{SENDEREMAIL}
				</li>
				<li class="list_item">
					{RECEIVEREMAIL}
				</li>
			</ul>
		</div>-->
</div>
		
		 
	</div>
			</div>
          
        </div><!--/span-->
      </div><!--/row-->
    </div><!--/.fluid-container-->
<div id="footer"></div>
</div>
<script type="text/javascript">
	$(document).ready(function() {
		/*CKEDITOR.disableAutoInline = true;
		$('div[class="editablecontent"]').each(function() {
					var editor = CKEDITOR.inline( this, {extraPlugins: 'tokens'} );
			});*/
			CKEDITOR.replace( 'message', {
			//toolbar : 'Basic',
			//uiColor : '#0579b3',
			//resize_enabled: false
			});
	});
	function valid_messageform2(){
		//var desc=$('#message').val();
		//alert(desc);return false;
		var flag=true;
		var subject=$('#subject').val();
		if(subject=='')
		{
			$('#errorSubject').html(newsletter_subject_message);
			flag=false;
			//alert("Please enter subject");return false;
		}else{
			$('#errorSubject').html("");
		}
		$('textarea[name="message"]').val(CKEDITOR.instances.message.getData());
		var desc=$('#message').val().replace("<p>","");
		desc=desc.replace("</p>","");
		if(desc=="")
		{
			$('#errorMessage').html(newsletter_description_message);
			flag=false;
			//alert("Please Enter message");			
			//return false;
		}else{
			$('#errorMessage').html("");
		}
		if(flag==true){	
			$.ajax({   
				type    	: "POST",
				url			: webServiceUrl+'sendnewsletter',
				datatype	:"json",
				data 		: {subject:subject,message:desc},
				   
				success: function(data){
				    if(data.value==1){
						$("#successmsg").addClass("success").html(newsletter_success_message).fadeIn('slow').delay(3000).fadeOut('slow');
						$("#subject").val('');						
						$('#message').val('');
					}else{
						$("#successmsg").html(data.status);
					}
				}   
			});
		}
	}	
	function add_tag(tag){
	  var desc=$('#messageform').find('.nicEdit-main').html();
	  $('#message').val(nicEditors.findEditor('message').getContent());
	  var cdesc=desc+"{"+tag+"}";
	  $('#message').val(nicEditors.findEditor('message').setContent(cdesc));  
   }
</script>

